byteAnd
Type
operator
Summary
Performs a "bitwise and" operation on each bit of two strings of binary data.
Syntax
<leftData> byteAnd <rightData>
Description
Use the byteAnd operator to operate directly on the bits of two binary strings.
For each bit of leftData, LiveCode performs an and operation with the corresponding bit of rightData to produce a result. A bit is 1 if the corresponding bits of leftData and rightData are both 1. Otherwise, the bit is 0.
If the leftData and rightData are different lengths, the bytes of the shorter binary string are repeatedly used in order to produce the result.
Parameters
Name | Type | Description |
---|---|---|
leftData | binary data, or an expression that evaluates to binary data | |
rightData | binary data, or an expression that evaluates to binary data |
Examples
/* Left data represented in memory as 00000011 00000010 */
local tLeftData
put numToByte(3) & numToByte(2) into tLeftData
/* Right data represented in memory as 00000010 00000001 */
local tRightData
put numToByte(2) & numToByte(1) into tRightData
/* Result represented in memory as 00000010 00000000 */
local tResult
put tLeftData byteAnd tRightData into tResult
/* Equivalent to using bitAnd and then converting to data */
put tResult is numToByte(3 bitAnd 2) & numToByte(2 bitAnd 1) -- true
Related
glossary: operation, operator, bit, binary, operand, binary data
Compatibility and Support
Introduced
LiveCode 10.0
OS
mac
windows
linux
ios
android
Platforms
desktop
server
mobile